<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        ul,ol{
            list-style: none;
        }
        .lunbo{
            position: relative;
            width: 880px;
            height: 550px;
            border: 1px solid #333;
            margin:20px auto;
        }
        .lunbo .pic li{
            position: absolute;
            top:0;
            left: 0;
            width: 880px;
            height: 550px;
            display: none;
        }
        .lunbo .pic .current{
            display: block;
        }
        .btn a{
            position: absolute;
            top:50%;
            margin-top:-25px;
            width: 50px;
            height: 50px;
            line-height: 50px;
            font-weight: bold;
            color: #fff;
            font:20px/50px "宋体";
            text-decoration: none;
            text-align: center;
            background:rgba(255, 2555, 2555, 0.3); 
        }
        .btn .leftbtn{
            left:0;
        }
        .btn .rightbtn{
            right:0;
        }
        .btn a:hover{
            background:rgba(255, 2555, 2555, 0.8);
        }
        .lunbo .sub{
            position: absolute;
            bottom: 10px;
            left: 40%;
            width: 300px;
            height: 50px; 
        }
        .lunbo .sub li{
            float: left;
            width: 20px;
            height: 20px;
            margin-left: 5px;
            border-radius: 20px;
            background:rgba(255, 2555, 2555, 0.3);
        }
        .lunbo .sub .current{
            background:rgba(255, 2555, 2555, 0.8);
        }
        .lunbo .sub li:hover{
            cursor: pointer;
            background:rgba(255, 2555, 2555, 0.8);
        }
    </style>
</head>
<body>
    <div class="lunbo" id="lunbo">
        <ul class="pic" id="pic">
            <li class="current"><img src="lunbo/c1.jpg" alt=""></li>
            <li><img src="lunbo/c2.jpg" alt=""></li>
            <li><img src="lunbo/c3.jpg" alt=""></li>
            <li><img src="lunbo/c4.jpg" alt=""></li>
            <li><img src="lunbo/c5.jpg" alt=""></li>
            <li><img src="lunbo/c6.jpg" alt=""></li>
        </ul>
        <div class="btn" id="btn">
            <a href="javascript:;" class="leftbtn" id="leftbtn">&lt;</a>
            <a href="javascript:;" class="rightbtn" id="rightbtn">&gt;</a>
        </div>
        <ol class="sub" id="sub">
            <li class="current"></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
        </ol>
    </div>
    <script>
        var lunbo = document.getElementById("lunbo");
        var pic = document.getElementById("pic");
        var lis = pic.children;
        // 按钮
        var leftbtn = document.getElementById("leftbtn");
        var rightbtn = document.getElementById("rightbtn");
        // 图标
        var sub = document.getElementById("sub");
        var olis = sub.children;

        // 定义全局变量
        var idx = 0;
        // 点击右按钮切换图片
        rightbtn.onclick = function(){
            idx++;
            if(idx >= lis.length){
                idx = 0;
            }
            leftClick();
        }
         // 点击左按钮切换图片
         leftbtn.onclick = function(){
             idx--;
             if(idx < 0){
                 idx = 5;
             }
             leftClick();
         }

        //  小圆点、
        for(var i = 0;i < olis.length; i++){
            olis[i].index = i;
            olis[i].onclick = function(){
                idx = this.index;
                leftClick();
            }
           
        }
        // 自定义函数
         function leftClick(){
            for(var i = 0; i < lis.length; i++){
                lis[i].className = "";
                olis[i].className = "";
            }
            lis[idx].className = "current";
            olis[idx].className = "current";
         }
    </script>
</body>
</html>